package com.woniuxy.kaer.shop.controller;


import cn.hutool.core.bean.BeanUtil;
import com.woniuxy.kaer.commons.util.Result;
import com.woniuxy.kaer.form.AddPointProductForm;
import com.woniuxy.kaer.param.AddPointProductParam;
import com.woniuxy.kaer.shop.service.PointProductService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * <p>
 *  积分商品
 * </p>
 *
 * @author 郭建东
 * @since 2025年02月17日
 */
@RestController
@RequestMapping("/pointProduct")
@Api(tags = "积分商品管理")
public class PointProductController {

    @Resource
    private PointProductService pointProductService;

    // 新增积分商品
    @PostMapping("/addPointProductForm")
    @ApiOperation("新增积分商品")
    public Result addPointProduct(@RequestBody AddPointProductForm form)throws Exception{
        pointProductService.addPointProduct(BeanUtil.toBean(form, AddPointProductParam.class));
        return Result.succeed("新增积分商品成功",null);
    }

    // 修改积分商品库存
    @PostMapping("updatePointProductForm")
    @ApiOperation("修改积分商品库存")
    public Result updateInventory(Integer pointProductId, Long inventory)throws Exception{
         pointProductService.updateInventory(pointProductId,inventory);
         return Result.succeed("修改积分商品库存成功",null);
    }

}

